package migrations

import (
	"database/sql"

	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/migrate"

	"gorm.io/gorm"
)

// http://sql2struct.atotoa.com/
func init() {

	type VehicleModel struct {
		models.BaseModel

		BrandId uint64 `gorm:"column:brand_id;comment:品牌id;" db:"brand_id" json:"brand_id" form:"brand_id"`
		Name    string `gorm:"type:varchar(255);comment:型号名称;" db:"name" json:"name" form:"name"`
		Year    int    `gorm:"column:year;comment:出厂年份;" db:"year" json:"year" form:"year"`

		models.CommonTimestampsField
	}

	up := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.AutoMigrate(&VehicleModel{})
	}

	down := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.DropTable(&VehicleModel{})
	}

	migrate.Add("2023_07_18_151712_add_vehicle_models_table", up, down)
}
